/*package org.domain.pseample.session;

import javax.servlet.sip.SipServletRequest;
import javax.servlet.sip.SipServletResponse;
import javax.servlet.sip.SipURI;

import org.apache.log4j.Logger;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Observer;
import org.jboss.seam.annotations.Scope;
import org.mobicents.mscontrol.MsConnection;
import org.mobicents.mscontrol.MsProvider;
import org.mobicents.mscontrol.MsSession;

@Name("sipMessageHandler")
@Scope(ScopeType.STATELESS)
public class SipMessageHandler {

	private static Logger logger = Logger.getLogger(SipMessageHandler.class);

	// The SipFactory is used to create SIP request and SIP URIs
	public static final String PR_JNDI_NAME = "media/trunk/PacketRelay/$";

	private void displayMessage(String message) {
		// StaticSharedStore.message = message;
		// makeDirty is what actually causes the refresh
		// StaticSharedStore.makeDirty();
	}

	@Observer("INVITE")
	public void doInvite(SipServletRequest request) throws Exception {
		// displayMessage("INVITE from " + request.getFrom());

		SipServletResponse response = request
				.createResponse(SipServletResponse.SC_RINGING);
		response.send();

		Object sdpObj = request.getContent();
		byte[] sdpBytes = (byte[]) sdpObj;
		String sdp = new String(sdpBytes);
		try {
			String user = request.getFrom().getDisplayName();
			if (user == null && request.getFrom().getURI() instanceof SipURI) {
				user = ((SipURI) request.getFrom().getURI()).getUser();
			}
			
			MapInstance mapInstance = MapInstanceManager.instance()
					.getMapInstance(user);

			if (mapInstance == null) {logger.info(user + " tried to connect");
				request.createResponse(SipServletResponse.SC_DECLINE).send();

			}

			else {
				 MsPeerFactory - to get MsPeer instance 
				 MsPeer - returns an instance of a Peer object 

				
				 * Returns an instance of Provider object which contains the
				 * desired service name
				 

				MsProvider msprovider = MsProviderCenter.getInstance()
						.getProvider();

				
				 * MsSession provides a transient association of connections for
				 * real-time communication interchange
				 
				 createSession() - creates a session with no links 

				MsSession mssession = msprovider.createSession();

				
				 * createNetworkConnection(identifier) - specifies the
				 * identifier of media server endpoint
				 
				MsConnection msconnection = mssession
						.createNetworkConnection(PR_JNDI_NAME);

				logger.info("caller's name" + user);

			
				logger.info("successfully acquired haspmap instance for "
						+ mapInstance.getUserName());

				MediaConnectionListener listener = new MediaConnectionListener(
						mapInstance);
				listener.setInviteRequest(request);
				msconnection.addConnectionListener(listener);
				msconnection.modify("$", sdp);

				logger.info("setting initialrequest in mapinstance" + request
						+ " for user " + user);

				mapInstance.setInitialRequest(request);

				logger.info("setting msconnection in mapinstance"
						+ msconnection + request + " for user " + user);

				mapInstance.setMsConnection(msconnection);

				logger.info("setting mediaconnected to true " + request
						+ " for user " + user);

				mapInstance.setMediaConnected(true);
				
				mapInstance.setBusy(false);

				logger.info("No exceptions");
			}
		} catch (Exception e) {
			e.printStackTrace();

		}

	}

	@Observer("BYE")
	public void doBye(SipServletRequest request) throws Exception {
		displayMessage("BYE from " + request.getFrom());
		request.createResponse(200).send();
	}

	@Observer("REGISTER")
	public void doRegister(SipServletRequest request) throws Exception {
		displayMessage("REGISTER from " + request.getFrom());
		request.createResponse(200).send();
	}

	@Observer("RESPONSE")
	public void doRegister(SipServletResponse response) throws Exception {
		if (response.getMethod().equalsIgnoreCase("INVITE")) {
			if (response.getStatus() >= 200 && response.getStatus() < 300) {
				response.createAck().send();
			}
		}
	}
}
*/